<?php
header('Content-Type:text/html; Charset=UTF-8');
require 'lib/checker.php';
require 'lib/db.php';
@$entrys = dbSelectAll('select id,name,imgUrl,price,type_id from entry order by id asc');
require 'lib/header.php';
?>
		<div class="container">
			<div class="row">
				<div class="col-xs-2">
                    <a href="dishAdd.php" class="btn btn-primary btn-lg btn-block">添加菜品</a>
                    <a href="main.php" class="btn btn-primary btn-lg btn-block">返回首页</a>
                </div>
                <div class="col-xs-8">
                	<div class="panel panel-primary">
                		<div class="panel-heading">
                			<div class="panel-title">
                                <span class="glyphicon glyphicon-th-list"></span> 菜品列表<span class="col-md-offset-8"></span>
                            </div>`
                		</div>
                		<div class="panel-body">
                			<div class="list-group">
                				<table class="table table-striped table-bordered table-hover text-center">
                					<tr>
					                	<td>序号</td>
					                	<td>菜品图片</td>
					                    <td>菜品名称</td>
					                    <td>菜品类型</td>
					                    <td>菜品单价</td>
					                    <td>关联订单</td>
					                    <td>操作方式</td>
					                </tr>
					                <?php foreach ($entrys as $entry){?>
					                	<?php @$type = dbSelect('select id,name from type where id=:id',array('id'=>$entry['type_id']));?>
						                <tr>
						                	<td><?php echo $entry['id']?></td>
						                    <td><img alt="砂锅白菜" style="height: 20px;" src="imgs/<?php echo $entry['imgUrl']?>"></td>
						                	<td><?php echo $entry['name']?></td>
						                    <td><?php echo $type['name']?></td>
						                    <td><?php echo $entry['price']?>元</td>
						                    <td><a href="#">查看</a></td>
						                    <td>
						                        <a href="dishEdit.php?id=<?php echo $entry['id'];?>">编辑</a>|
						                        <a href="#delete<?php echo $entry['id'];?>" data-toggle="modal">删除</a>
						                        <div class="modal fade" id="delete<?php echo $entry['id'];?>" tabindex="-1" >
						                        	<div class="modal-dialog">
						                        		<div class="modal-content">
						                        			<div class="modal-header">
						                        				<button type="button" class="close" data-dismiss="modal">
						                        					<span>&times;</span><span class="sr-only">Close</span>
						                        				</button>
						                        				<h4 class="modal-title">确定删除[<?php echo $entry['name']?>]</h4>
						                        			</div>
						                        			<form class="form-horizontal" action="doDeleteDish.php" method="post" >
						                        			<div class="modal-body">
						                        			     你确定要删除菜品[<?php echo $entry['name']?>]吗？
		                                        				<input type="hidden" name="id" value="<?php echo $entry['id'];?>"/>
						                        			</div>
						                        			<div class="modal-footer">
						                        				<button type="submit" class="btn btn-default">确定</button>
						                        				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
						                        			</div>
						                        			</form>
						                        		</div>
						                        	</div>
						                        </div>
						                    </td>
						                </tr>
					                <?php }?>
                				</table>
                			</div>
                		</div>
                	</div>
                </div>
			</div>
		</div>
   </body>
</html>